#include <bits/stdc++.h>
using namespace std;

const int maxn=1e5+10;
int a[maxn];
int block[maxn];
int l[maxn/2];
int r[maxn/2];
int n,m;
int blocksize;
vector <int> sortblock[maxn/2];


int ask(int l,int r,int p)
{
	int ans=0;
	int start=block[l];
	int end=block[r];
	if(start==end)
	{
		
	}
	
	
	
}

void update(int p,int k)
{
	a[p]=k;

	
	
	
	
}



















int main()
{
	cin >> n >> m;
	blocksize=sqrt(n);
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		block[i]=(i-1)/blocksize+1;
		if(block[i]!=block[i-1])
		{
			l[block[i]]=i;
			r[block[i-1]]=i-1;
		}
	}

	while(m--)
	{
		int l,r,p;
		cin >> l >> r >> p;
		int k=ask(l,r,p);
		cout << k << endl;
		update(p,k);
	}
	return 0;
}

